<template>
<div class="container">
    <div class="login">
        <div class="item">
            <h2>家族族谱管理系统</h2>
        </div>
        <el-form :model="loginID" :rules="loginRules" ref="loginID" label-width="0px" class="login_id">
       <el-form-item prop="username">
          <el-input v-model="loginID.username" placeholder="请输入账号" ></el-input>
        </el-form-item>
        <el-form-item prop="password">
          <el-input v-model="loginID.password" type = 'password' placeholder-size="mini" placeholder="请输入登录密码" ></el-input>
        </el-form-item>
        <el-form-item class="login_button">
            <sapn>
          <el-button type="primary" @click="submitForm('loginID')">登录</el-button>
          <el-button @click="resetForm('loginID')">重置</el-button>
          </sapn>
        </el-form-item>
      </el-form>
    </div>
  </div>
</template>

<script>
  import {reactive,toRefs} from 'vue'
   import {User} from '@element-plus/icons' 
    export default {
    name: 'Login',
    components:{
  User
},
   data() {
      return {
        loginID: {
          username: 'qjx1112',
          password: '12345678',
        },
        loginRules: {
          username: [
            { required: true,message: '请输入用户名称', trigger: 'blur' },
            { min: 3, max: 16, message: '长度在 3 到 16 个字符', trigger: 'blur' }
          ],
          password: [
            { required: true, message: '请输入登录密码', trigger: 'blur' },
            { min: 3, max: 16, message: '长度在 3 到 16 个字符', trigger: 'blur' }
          ]
        }
      };
    },
    methods: {
      submitForm(formName) {
        this.$refs[formName].validate((valid) => {
          if (valid) {
            this.$router.push("/layout");
          } else {
            console.log('error submit!!');
            return false;
          }
        });
      },
      resetForm(formName) {
        this.$refs[formName].resetFields();
      }
    }
  }
</script>
<style lang="scss" scoped>

.container{
   width: 100vw;
    height: 100vh;
    display: flex;
    justify-content: center;
    align-items: center;
    background-size: 100% 100%;
    background-image: url('background.png');
    
    //登录框
    .login{
         width:400px;
         height: 250px;
         border: 3px solid rgb(255, 255, 255);
        border-radius: 20px;
        //字体颜色
        color: rgb(0, 0, 0);
        padding: 10px;   
        background-color: rgba($color: #e3d7d7, $alpha: 0.3);
        .item{
            font-size: 16px;
            display: flex;
            align-items: center;
            margin: 20px 10px;

            h2{
                flex: 1;
                text-align: center;
            }
             span{
                width: 60px;
                text-align: center;
            }
            div{
                flex: 1;
            }

        }
    }
}
</style>
